import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:mtf/app/modules/login_module/login_controller.dart';
import 'package:mtf/app/widget/AppBarLeftTitle.dart';

import '../../../R.dart';
import '../../theme/app_colors.dart';
/**
 * GetX Template Generator - fb.com/htngu.99
 * */

class loginPage extends GetView<loginController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: Container(
        width: double.infinity,
        height: double.infinity,
        child: Padding(
          padding: const EdgeInsets.fromLTRB(24, 100, 24, 70),
          child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Align(alignment: Alignment.center,child: Column(children: [

                  Text("登录",
                      style: TextStyle(
                          fontSize: 28,
                          fontWeight: FontWeight.bold,
                          color: c_333333)),
                  SizedBox(height: 20,),
                  Image.asset(R.assetsImgIcAppLogo,height: 60,width: 60,)

                ],),),
                Container(
                  margin: const EdgeInsets.only(top: 40),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(25),
                    color: c_f3f5f7,
                  ),
                  child: TextField(
                    keyboardType: TextInputType.phone,
                    decoration: InputDecoration(
                      contentPadding: const EdgeInsets.fromLTRB(20, 14, 20, 14),
                      hintText: "请输入您的手机号",
                      hintStyle: TextStyle(fontSize: 14, color: c_999999),
                      prefixIcon: Padding(
                        padding: const EdgeInsets.all(15.0),
                        child: SvgPicture.asset(R.assetsImgIcSvgPhone),
                      ),
                      border: InputBorder.none,
                    ),
                    style: TextStyle(color: c_333333, fontSize: 14),
                    controller: controller.phoneController,
                  ),
                ),
                Container(
                  margin: const EdgeInsets.only(top: 15),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(25),
                    color: c_f3f5f7,
                  ),
                  child: Obx(() {
                    return TextField(
                      obscureText: controller.Obscure,
                      decoration: InputDecoration(
                        contentPadding:
                            const EdgeInsets.fromLTRB(20, 14, 20, 14),
                        hintText: "请输入密码",
                        hintStyle: TextStyle(fontSize: 14, color: c_999999),
                        prefixIcon: Padding(
                          padding: const EdgeInsets.all(15.0),
                          child: SvgPicture.asset(R.assetsImgIcSvgPsw),
                        ),
                        suffixIcon: IconButton(
                          splashColor: Colors.transparent,
                          iconSize: 18,
                          icon: Icon(controller.Obscure
                              ? Icons.visibility
                              : Icons.visibility_off),
                          onPressed: () {
                            controller.Obscure = !controller.Obscure;
                          },
                        ),
                        border: InputBorder.none,
                      ),
                      style: TextStyle(color: c_333333, fontSize: 14),
                      controller: controller.passwordController,
                    );
                  }),
                ),
                // Container(
                //   margin: const EdgeInsets.only(top: 15),
                //   padding: EdgeInsets.only(right: 15),
                //   decoration: BoxDecoration(
                //     borderRadius: BorderRadius.circular(25),
                //     color: c_f3f5f7,
                //   ),
                //   child: Row(
                //     mainAxisSize: MainAxisSize.max,
                //     children: [
                //       Expanded(
                //         flex: 1,
                //         child: TextField(
                //           decoration: InputDecoration(
                //             contentPadding:
                //                 const EdgeInsets.fromLTRB(20, 14, 20, 14),
                //             hintText: "请输入验证码",
                //             hintStyle: TextStyle(fontSize: 14, color: c_999999),
                //             prefixIcon: Padding(
                //               padding: const EdgeInsets.all(15.0),
                //               child: SvgPicture.asset(R.assetsImgIcSvgYzm),
                //             ),
                //             border: InputBorder.none,
                //           ),
                //           style: TextStyle(color: c_333333, fontSize: 14),
                //           controller: controller.yzmController,
                //         ),
                //       ),
                //       SizedBox(
                //         width: 64,
                //         height: 32,
                //         child: Image.network(
                //           "http://p2.music.126.net/GvYQoflE99eoeGi9jG4Bsw==/109951165375336156.jpg",
                //           fit: BoxFit.fill,
                //         ),
                //       )
                //     ],
                //   ),
                // ),
                Center(
                    child: Container(
                      margin: const EdgeInsets.only(top: 32),
                      width: double.maxFinite,
                      height: 48,
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(24),
                        color: c_f12f38,
                      ),
                      child: TextButton(
                        child: Text("登录", style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold)),
                        onPressed: () {
                          controller.login();
                        }
                      ),
                    )),
                Container(
                    child: Flex(mainAxisAlignment: MainAxisAlignment.spaceBetween,direction: Axis.horizontal,children: [
                  TextButton(
                      child: Text("忘记密码？", style: TextStyle(color: c_666666, fontSize: 14)),
                      onPressed: () {
                        controller.clickForgetPsw();
                      }
                  ),
                  TextButton(
                      child: Text("注册", style: TextStyle(color: c_666666, fontSize: 14)),
                      onPressed: () {
                        controller.clickRegister();
                      }
                  )
                ],))
              ]),
        ),
      ),
    );
  }
}
